//
//  MTURLRequest.h
//  MobTimes
//
//  Created by 江山 王 on 4/30/12.
//  Copyright (c) 2012 Finalist. All rights reserved.
//

#import <Foundation/Foundation.h>

@protocol MTURLRequestDelegate;

@interface MTURLRequest : NSObject {
    id _delegate;
    NSString *_urlString;
    NSTimeInterval _timeout;
    NSURLConnection *_conn;
    NSError *_error;
    NSMutableData *_responseData;
}

@property (nonatomic, assign)id delegate;
@property (nonatomic, retain)NSString *urlString;
@property (nonatomic, assign)NSTimeInterval timeout;
@property (nonatomic, retain)NSURLConnection *conn;
@property (nonatomic, retain)NSError *error;
@property (nonatomic, retain)NSMutableData *responseData;

- (id)initWithDelegate:(id)delegateParam;

- (void)sendAsynchrously;

@end

@protocol MTURLRequestDelegate
@optional
- (void)requestDidStartLoad:(MTURLRequest *)request;

- (void)requestDidFinishLoad:(MTURLRequest *)request;

- (void)request:(MTURLRequest *)request didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge*)challenge;

- (void)request:(MTURLRequest *)request didFailLoadWithError:(NSError*)error;

- (void)requestDidCancelLoad:(MTURLRequest *)request;

@end